#ifndef HEADER_TRIANGLE_MESH_HPP
#define HEADER_TRIANGLE_MESH_HPP

#include <vector>
#include "btBulletDynamicsCommon.h"

#include "physics/user_pointer.hpp"

class Material;

class TriangleMesh
{
private:
	UserPointer m_user_pointer;
	std::vector<const Material*> m_triangleIndex2Material;
	btRigidBody* m_body;
	btTriangleMesh m_mesh;
	btDefaultMotionState* m_motion_state;
	btCollisionShape* m_collision_shape;
public:
	TriangleMesh(): m_mesh() {}
	~TriangleMesh();
	void addTriangle(const btVector3& t1, const btVector3& t2,
					 const btVector3& t3, const Material* m);
	void createBody(btCollisionObject::CollisionFlags flags = 
					(btCollisionObject::CollisionFlags)0);
	void removeBody();
	const Material* getMaterial(int n) const
	{
		return m_triangleIndex2Material[n];
	}
};

#endif
